Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
panic.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Roc authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/target_stdio/roc_core/panic.h
10//! @brief Panic function.
11
12#ifndef ROC_CORE_PANIC_H_
13#define ROC_CORE_PANIC_H_
14
15#include "roc_core/attributes.h"
16#include "roc_core/helpers.h"
17
18#ifndef ROC_MODULE
19#error "ROC_MODULE not defined"
20#endif
21
22//! Panic if condition is true.
23//! @note
24//! This is a shorthand; roc_panic() with a meaningful error message is
25//! preferred way to panic.
26#define roc_panic_if(x) \
27 do { \
28 if ((x)) { \
29 roc_panic("%s", #x); \
30 } \
31 } while (0)
32
33//! Panic if condition is false.
34//! @note
35//! This is a shorthand; roc_panic() with a meaningful error message is
36//! preferred way to panic.
37#define roc_panic_if_not(x) roc_panic_if(!(x))
38
39//! Print error message and terminate program gracefully.
40//! @remarks
41//! Never returns and never throws.
42#define roc_panic(...) \
43 ::roc::core::panic(ROC_STRINGIZE(ROC_MODULE), __FILE__, __LINE__, __VA_ARGS__)
44
45namespace roc {
46namespace core {
47
48//! Print error message and terminate program gracefully.
49void panic(const char* module, const char* file, int line, const char* format, ...)
51
52} // namespace core
53} // namespace roc
54
55#endif // ROC_CORE_PANIC_H_
GCC attributes.
#define ROC_ATTR_PRINTF(n_fmt_arg, n_var_arg)
Function gets printf-like arguments.
Definition: attributes.h:28
#define ROC_ATTR_NORETURN
Function never returns.
Definition: attributes.h:19
Compile time helpers.
void panic(const char *module, const char *file, int line, const char *format,...) ROC_ATTR_NORETURN ROC_ATTR_PRINTF(4
Print error message and terminate program gracefully.
Root namespace.